<?php
declare (strict_types = 1);

//商品模块 验证器
// +----------------------------------------------------------------------
// |
// +----------------------------------------------------------------------

namespace app\admin\validate\mall;

use think\Validate;

class Item extends Validate
{

    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */

    protected $rule = [
        'title' => 'require|unique:item',
        'goods_no' => 'require|unique:item',
        'thumb' => 'require',
        'category_id' => 'require',
        'image' => 'require',
        'type' => 'require',
        'content' => 'require',
        'spec' => 'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */

    protected $message = [
        'title.require'    => '商品标题必填',
        'title.unique'    => '商品标题重复',
        'goods_no.unique'    => '商品货号重复',
        'goods_no.require'    => '商品货号必填',
        'category_id.require'    => '商品分类必填',
        'image.require'    => '轮播图必填',
        'thumb.require'    => '主图必填',
        'content.require'    => '内容必填',
        'spec.require'    => '规格必填',
        'type.require'    => '类型必填',

    ];

    /**
     * 验证场景
     * @var array
     */

    protected $scene = [
        'add'   =>  [
            'title','goods_no','thumb','category_id','image','content','spec','type'
        ],
        'edit'  =>  [
            'title','goods_no','thumb','category_id','image','content','spec','type'

        ],
    ];


}